package borge.web.teamspirit.server;

import java.util.ArrayList;
import java.util.List;

import javax.jdo.annotations.Embedded;
import javax.jdo.annotations.EmbeddedOnly;
import javax.jdo.annotations.Extension;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Test {

	@PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    @Extension(vendorName="datanucleus", key="gae.encoded-pk", value="true")
    private String iEncodedKey;
	
	@Persistent(defaultFetchGroup = "true")
	private List<InnerTest> innerTests;
	
    @PersistenceCapable
    @EmbeddedOnly
	public static class InnerTest{

    	@Persistent
    	private String whatever;
    	
    	public InnerTest(){
    		whatever = "whatever";
    	}
	}

    public Test(){ }
    
    public String getKey(){
    	return iEncodedKey;
    }
    
    public void addSomeInnerTests(){
    	innerTests = new ArrayList<InnerTest>();
    	
    	for(int i = 0; i < 5; ++i)
    		innerTests.add(new InnerTest());
    }
	
    public List<InnerTest> getInnerTests(){
    	return innerTests;
    }
}
